oo::class create GoToMenu {
    superclass AppMenu
    variable Menu Label NotebookObj Notebook PopupGotoDialog

    constructor {menubar} {
        next $menubar goto
        set PopupGotoDialog [PopupGotoDialog new .goto]
    }

    method createMenu {} {
        foreach row {
            {command {{Next char} C-f {} {}}}
            {command {{Prev char} C-b {} {}}}
            {separator {}}
            {command {{Next word} C-Right {} {}}}
            {command {{Prev word} C-Left {} {}}}
            {separator {}}
            {command {{Prev line} C-p {} {}}}
            {command {{Next line} C-n {} {}}}
            {command {{Line start} C-a {} {}}}
            {command {{Line end} C-e {} {}}}
            {command {{Content head} A-a {} gotoContentHead}}
            {separator {}}
            {command {{Document head} C-Home {} {}}}
            {command {{Document end} C-End {} {}}}
            {separator {}}
            {command {{Go to} C-g {} gotoLine}}
        } {
            my createItem $row
        }
    }

    method gotoContentHead {} {
        set containerObj [$NotebookObj getContainObj \
                              [$Notebook index current]]
        set codePad [set [info object namespace $containerObj]::CodePad]
        set langObj [set [info object namespace $codePad]::Language]
        set padWidget [set [info object namespace $codePad]::PadWidget]

        $padWidget mark set insert \
            "insert linestart +[$langObj getLineHeadSpacing $padWidget insert]c"
    }

    method gotoLine {} {
        set line [$PopupGotoDialog popup "Go to line"]
        if {$line != {}} {
            set padWidget [my getCurrentPadWidget]
            $padWidget mark set insert $line.0
            $padWidget see insert
        }
    }
}